package com.ruoyi.project.system.controller;

import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.project.system.domain.dto.SystemDTO;
import com.ruoyi.project.system.service.SystemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 系统控制器（适配前端传参字段名：identity）
 */
@RestController
@RequestMapping("/system/prescription")
public class SystemController {

    @Autowired
    private SystemService systemService;

    /**
     * 查询患者身份证下的所有有效预约记录（前端传参字段名：identity）
     */
    @PostMapping("/queryAllReservations")
    public AjaxResult queryAllReservations(
            @Validated @RequestBody SystemDTO.PatientIdentityRequest request) {

        // 核心修改：获取前端传的 identity 字段（原request.getPatientIdentityNumber()）
        SystemDTO.AllReservationsResponse response = systemService.queryAllReservations(
                request.getIdentity());

        // 返回结果（不变）
        return AjaxResult.success("预约记录查询成功", response);
    }
}